package org.ricks.condition1;

import org.ricks.condition1.entity.Achievement;
import org.ricks.condition1.entity.Task;
import org.ricks.condition1.event.TaskCompletedEvent;
import org.ricks.condition1.event.LevelUpEvent;
import org.ricks.ioc.event.EventBus;

// 任务条件构建
public class TaskConditionBuilder {

    public static Condition createLevelCondition(Task task) {
        return new GenericProgressCondition<>(
                task.getTargetValue(),
                LevelUpEvent.class,
                (current, event) -> Math.max(current, event.newLevel()),
                condition -> EventBus.post(new TaskCompletedEvent(task))
        );
    }


    // 成就进度条件
//    public static Condition createAchievementCondition(Achievement achievement) {
//        return new GenericProgressCondition<>(
//                achievement.getTargetValue(),
//                LevelUpEvent.class,
//                (current, event) -> Math.max(current, event.newLevel()),
//                condition -> EventBus.post(new AchievementUnlockedEvent(achievement))
//        );
//    }
}
